/*
 *  BCWorldObserver.h
 *  roborobo-online
 *
 *  Created by Antonio Gonzalez on 29/04/10.
 *
 */



#ifndef BIRTHCLINIC_H
#define BIRTHCLINIC_H

#include "RoboroboMain/common.h"
#include "RoboroboMain/roborobo.h"
#include "BirthClinic/include/BCGenotype.h"

#include "Observers/WorldObserver.h"
#include "Coord2d.h"

class World;

class BirthClinic : public WorldObserver
{
	protected:
		
	public:
		BirthClinic( World *__world );
		~BirthClinic();
				
		void reset();
		void step();
		void printReceivedGenomes();

	private:
		void initWorld();
		bool loadFiles();
		void createRandomOrganism();
		int _nbOfCreatedOrganism;
		int _step;
		int _numComponents;

		bool isEmpty();
		void updateWorld();

		std::vector<int> _parentsId;
		std::vector<BCGenotype*> _receivedGenotypes;

		int getGenotypePosition(int id_);
		bool addGenotype(BCGenotype* gen_, int parentId_);

		std::vector<int> getMainOrganismIds();
		int proportionalSelection(std::map<int, int> list_);
		void writeStatistics();
};

#endif

